function Prompt(elems, context,closecallback) {
  this.context = context ? context : $(document.body);
  this.eles = [];
  this.closecallback=closecallback;
  if (elems) {
    for (var i = 0; i < elems.length; i++) {
      this.eles.push($('<div></div>').attr('id', elems[i].id));
      if (elems[i].html) {
        this.eles[i].html(elems[i].html);
      }
      if (elems[i].style) {
        this.eles[i].css(elems[i].style);
      }
      if (elems[i].handler && typeof elems[i].handler == 'function') {
        elems[i].handler.call(this.eles[i], this);
      }
	  if (elems[i].className) {
        this.eles[i].addClass(elems[i].className);
      }
	  if(elems[i].closed===true){
		  elems[i].on('click',function(){
 			 this.close();
 		  });
	  }
      this.eles[i].appendTo(this.context);
    }
  }
}

Prompt.prototype.close = function() {
  var elems = this.eles;
  for (var i = elems.length - 1; i >= 0; i--) {
    elems[i].remove();
  }
  if(this.closecallback)
	  this.closecallback();
}

function LoadPrompt(elems) {
	var $this=this;
	elems[0].handler=function() {
      var target = $(window);
      this.height(target.height());
      this.width(target.width());
      if(elems[0].closed===true){
    	  this.on('click',function(){
    			 $this.close(); 
    		  });
      }
    };
    Prompt.call(this, elems);
}

function UserPrompt(html,func) {
	  Prompt.call(this, [{
	    id : 'mask_more',
	    handler : function(prompt) {
	      var target = $(window);
	      this.height(target.height());
	      this.width(target.width());
	    }
	  }, {
	    id : 'make_sure',
	    html : '<p>' + html + '</p><div class="input_ok" id="confirm">确定</div>',
	    handler : function(prompt) {
	      $(document).on('click', '#confirm', function() {
	        prompt.close.call(prompt);
	      });
	    }
	  }],null,func);
	}

UserPrompt.prototype=LoadPrompt.prototype = new Prompt();